#ifndef MANAGER_H
#define MANAGER_H

#include "AReVi/arObject.h"
#include "AReVi/Lib3D/renderer3D.h"
using namespace AReVi;

#include "connector.h"
class Environment;
class Element;
class Event;

/** Description */
class Manager : public ArObject {
public:
    AR_CLASS(Manager)
    
    /** Static context for singleton */
    static void createManager(ArRef<Connector> connector);
    /** Retreive the singleton Manager */
    static ArRef<Manager> getInstance(void);
    
    /** Retreive the connector */
    inline ArRef<Connector> getConnector(void) const {return _connector;}
    /** Retreive the environment */
    inline ArRef<Environment> getEnvironment(void) const {return _environment;}
    /** Retreive the renderer */
    inline ArRef<Renderer3D> getRenderer(void) const {return _renderer;}
    
    /** broadcast event */
    inline void broadcast(ArRef<Event> evt) const {_connector->broadcast(evt);}
    
    
protected:
    AR_CONSTRUCTOR_1(Manager, ArRef<Connector>, connector)

    /** To clear local elements on exit */
    void _onClose(const Renderer3D::CloseEvent & evt);

    ArRef<Connector> _connector;
    ArRef<Environment> _environment;
    ArRef<Renderer3D> _renderer;
    ArRef<AbstractInteractor> _interactor;
    static ArRef<Manager> _uniqueInstance;
};

#endif
